const path = require("path")
const express = require("express");
const app = express()


app.use(require("./imgrejectMiddleware"))
const staticRoot = path.resolve(__dirname, "../public");
// app.use(require("./imgrejectMiddleware.js"))
app.use(express.static(staticRoot))
app.use(express.urlencoded({
    extended: true
}))
// 参数格式为json
app.use(express.json())

const cookieParser = require("cookie-parser")
app.use(cookieParser())
app.use(require("./tokenMiddleware"))

app.use("/getboke", require("./api/bokeapi"))
app.use("/addly", require("./api/lyapi"))
app.use("/getxqss",require("./api/xqssapi"))
app.use("/getly",require("./api/lyapi"))
app.use("/getpl",require("./api/plapi"))
app.use("/addpl", require("./api/plapi"))

//用户中间件
app.use("/api/admin",require("./api/adminapi"))
//文件上传接口
app.use("/api/upload", require("./api/upload"))
// app.use("/api/admin", require("./api/adminapi"))

// 处理错误
app.use(require("./errorMiddleware"))


let port = 3306;
app.listen(port, () => {
    console.log("服务器启动")
})

